
{layout name="layout/layout" /}
<div class="register_head">
    <img id="back" src="__STATIC__/index/img/return.png">
    <p>填写意见反馈</p>
</div>
<div class="main">
    <div class="submit_title">建议类型：{$title}</div>
    <form onsubmit="return mySubmit();" id="form" method="post" action="{:Url('index/feedback/create')}" enctype="multipart/form-data">
        <div class="submit_content">
            <textarea required name="content" placeholder="请输入您发的反馈意见（字数1000字以内）"  maxlength="1000"></textarea>
        </div>
        <div class="submit_upload">
            <div>
                <div class="hide_file">
                    <div id="dd" class="img_content">
                    </div>
                    <img src="__STATIC__/index/img/upload.png" width="80px" height="80px">
                    <input style="border: 1px solid red;z-index: 999" type="file"  name="file[]" id="doc" multiple="multiple" onchange="javascript:setImagePreviews();" accept="image/*" />
                    <span>上传图片</span>
                </div>
            </div>

        </div>
        <div class="submit_phone">
            用户名<span>{$user.user_name}</span>
            <input name="user_id" value="{$_SESSION['user_id']}" type="hidden">
        </div>
        <div class="submit_phone">
            手机号码<span><input id="tel" type="tel" required  name="tel" value="{$tel['0']}"></span>
        </div>
        <input type="hidden" name="project_id" value="{$project_id}">
        <input type="hidden" name="title" value="{$title_id}">
        <input type="hidden" name="title" value="1">
        <input type="hidden" name="type" value="{$type}">
        <button class="regist" type="submit">提交反馈</button>
    </form>
</div>
<script>
  // 取消提示的http地址显示
    window.alert = function(name) {
        var iframe = document.createElement("IFRAME");
        iframe.style.display = "none";
        iframe.setAttribute("src", 'data:text/plain,');
        document.documentElement.appendChild(iframe);
        window.frames[0].window.alert(name);
        iframe.parentNode.removeChild(iframe);
    }
    $(function(){
        $("#back").click(function(){
            window.history.go(-1);
        });
    })
</script>
<style type="text/css">
    .img_content{
        display: table; 
        width: 100%;
        margin-bottom: 5px;
    }
    .img_style{
        float: left;
        width: 25%;
        margin-bottom: 5px;
    }
    .img_style img{
        object-fit:cover;
        height: 80px;
        max-width: 100%;     
        float: none;   
        margin:auto;
    }
</style>
<script type="text/javascript">
    $(function(){
        function mySubmit(flag){
            return flag;
        }
        $("#form").submit(function(){
            var tel = $('#tel').val();
        if(tel.length != 11){
            alert('请填写正确的手机号！');
            return false;
        }



        });

    })


    //下面用于多图片上传预览功能

    function setImagePreviews(avalue) {

        var docObj = document.getElementById("doc");

        var dd = document.getElementById("dd");

        dd.innerHTML = "";

        var fileList = docObj.files;

        for (var i = 0; i < fileList.length; i++) {



            dd.innerHTML += "<div  class='img_style' > <img id='img" + i + "'  /> </div>";

            var imgObjPreview = document.getElementById("img"+i);

            if (docObj.files && docObj.files[i]) {

                //火狐下，直接设img属性

                imgObjPreview.style.display = 'block';

                imgObjPreview.style.width = '80px';

                imgObjPreview.style.height = '80px';

                //imgObjPreview.src = docObj.files[0].getAsDataURL();

                //火狐7以上版本不能用上面的getAsDataURL()方式获取，需要一下方式

                imgObjPreview.src = window.URL.createObjectURL(docObj.files[i]);

            }

            else {

                //IE下，使用滤镜

                docObj.select();

                var imgSrc = document.selection.createRange().text;

                alert(imgSrc)

                var localImagId = document.getElementById("img" + i);

                //必须设置初始大小

                localImagId.style.width = "150px";

                localImagId.style.height = "180px";

                //图片异常的捕捉，防止用户修改后缀来伪造图片

                try {

                    localImagId.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";

                    localImagId.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgSrc;

                }

                catch (e) {

                    alert("您上传的图片格式不正确，请重新选择!");

                    return false;

                }

                imgObjPreview.style.display = 'none';

                document.selection.empty();

            }


        }



        return true;

    }



</script>